//
//  ZJAdviserVC.m
//  这家测试项目
//
//  Created by IOS_DEVELOPER on 2017/7/12.
//  Copyright © 2017年 陈志凌. All rights reserved.
//

#import "ZJAdviserVC.h"

@interface ZJAdviserVC ()
@property (weak, nonatomic) IBOutlet UIImageView *headImg;
@property (weak, nonatomic) IBOutlet UILabel *name;
@property (weak, nonatomic) IBOutlet UILabel *sex;
@property (weak, nonatomic) IBOutlet UILabel *phone;
@property (weak, nonatomic) IBOutlet UIImageView *topImg;
@property (weak, nonatomic) IBOutlet UIButton *phoneBtn;

@end

@implementation ZJAdviserVC

- (void)viewDidLoad {
    [super viewDidLoad];

    self.headImg.layer.masksToBounds = YES;
    self.headImg.layer.cornerRadius = 95/2;
    [self.phoneBtn setImage:[UIImage imageWithContentsOfFile:[Utils imgPath:@"wdzh_icon_phone@3x.png"]] forState:0];

    [self.headImg sd_setImageWithURL:[NSURL URLWithString:self.dict[@"pic_url"]] placeholderImage:[UIImage imageNamed:KUserHeadPhoto]];

    self.name.text = self.dict[@"realname"];
    self.phone.text = self.dict[@"mobile"];
    if([self.dict[@"gender"] integerValue] == 1){
        self.sex.text = @"先生";
    }else{
        self.sex.text = @"女士";
    }
}

- (IBAction)callBtn:(UIButton *)sender {
    
    NSString * phoneNum = self.dict[@"mobile"];
    NSString *callPhone = [NSString stringWithFormat:@"telprompt://%@", phoneNum];
    NSComparisonResult compare = [[UIDevice currentDevice].systemVersion compare:@"10.0"];
    if (compare == NSOrderedDescending || compare == NSOrderedSame) {
        /// 大于等于10.0系统使用此openURL方法
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:callPhone] options:@{} completionHandler:nil];
    } else {
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:callPhone]];
    }

}

@end
